﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Runtime.Serialization;

namespace OMSService
{
    [DataContract]
    public class OrderModel
    {
        int id;
        string orderNumber;
        int customerId;
        decimal totalPrice;
        string status;
        DateTime dateOfOrdering;
        DateTime prefDeliveryDate;
        DateTime deliveryDate;
        List<OrderItemModel> orderItems;
        CreditCardModel card;
        int? merchId;


        public OrderModel() { }
        public OrderModel(int customerId, decimal totalPrice, string status, 
            DateTime dateOfOrdering, DateTime prefDeliveryDate, DateTime deliveryDate, List<OrderItemModel> orderItems, int merchId)
        {
            CustomerId = customerId;
            Status = status;
            TotalPrice = totalPrice;
            Status = status;
            DateOfOrdering = dateOfOrdering;
            PrefDeliveryDate = prefDeliveryDate;
            DeliveryDate = deliveryDate;
            OrderItems = orderItems;
            MerchId = merchId;
        }
        public OrderModel(Order order)
        {
            Id = order.Id;
            CustomerId = order.CustomerId;
            TotalPrice = order.TotalPrice;
            Status = order.Status;
            DateOfOrdering = order.DateOfOrdering;
            PrefDeliveryDate = order.PrefDeliveryDate;
            DeliveryDate = order.DeliveryDate;
            OrderItems = new List<OrderItemModel>();
            OrderNumber = order.OrderNumber;
            foreach (OrderItem orderItem in order.OrderItems)
            {
                OrderItems.Add(new OrderItemModel(orderItem));
            }
            MerchId = order.MerchId;
        }
        #region setters
        [DataMember]
        public int Id
        {
            get { return id; }
            private set { id = value; }
        }

        [DataMember]
        public string OrderNumber
        {
            get { return orderNumber; }
            set { orderNumber = value; }
        }

        [DataMember]
        public int CustomerId
        {
            get { return customerId; }
            set { customerId = value; }
        }

        [DataMember]
        public decimal TotalPrice
        {
            get { return totalPrice; }
            set { totalPrice = value; }
        }

        [DataMember]
        public string Status
        {
            get { return status; }
            set { status = value; }
        }

        [DataMember]
        public DateTime DateOfOrdering
        {
            get { return dateOfOrdering; }
            set { dateOfOrdering = value; }
        }

        [DataMember]
        public DateTime PrefDeliveryDate
        {
            get { return prefDeliveryDate; }
            set { prefDeliveryDate = value; }
        }

        [DataMember]
        public DateTime DeliveryDate
        {
            get { return deliveryDate; }
            set { deliveryDate = value; }
        }

        [DataMember]
        public int? MerchId
        {
            get { return merchId; }
            private set { merchId = value; }
        }

        [DataMember]
        public List<OrderItemModel> OrderItems
        {
            get { return orderItems; }
            set { orderItems = value; }
        }

        [DataMember]
        public CreditCardModel Card
        {
            get { return card; }
            set { card = value; }
        }
    }
    #endregion
}


